package com.lipi.mall.order.service.impl;

import com.rabbitmq.client.AMQP;
import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.boot.autoconfigure.amqp.RabbitProperties;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lipi.common.utils.PageUtils;
import com.lipi.common.utils.Query;

import com.lipi.mall.order.dao.OrderItemDao;
import com.lipi.mall.order.entity.OrderItemEntity;
import com.lipi.mall.order.service.OrderItemService;


@Service("orderItemService")
@Slf4j
public class OrderItemServiceImpl extends ServiceImpl<OrderItemDao, OrderItemEntity> implements OrderItemService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<OrderItemEntity> page = this.page(
                new Query<OrderItemEntity>().getPage(params),
                new QueryWrapper<OrderItemEntity>()
        );

        return new PageUtils(page);
    }

    /**
     * 监听消息队列
     * @param message 获得的消息
     * 可选入参
     * org.springframework.amqp.core.Message 原生消息类 头+体
     * ${class}     实际上传的类,可由spring直接拿到
     * com.rabbitmq.client.Channel   当前传输数据的通道
     */
    @RabbitListener(queues = {"hello-java-queue"})
    public void receiveMessage(Message message) {
        log.info("接收到消息：{}，消息类型：{}",message,message);
    }
}